package wtws.message.detail;

import java.nio.ByteBuffer;

import wtws.util.ByteUtil;

public class GraphicMicroBustProductSubBlock {

	public static final int MSG_LEN = 36;
	private int microburstShapeRadius;
	private short solidShape;
	private int shapeAngularOrientation;
	private int centerPoint1XCoordinate;
	private int centerPoint1YCoordinate;
	private int centerPoint2XCoordinate;
	private int centerPoint2YCoordinate;
	private int lineSegment1Point1XCoor;
	private int lineSegment1Point1YCoor;
	private int lineSegment1Point2XCoor;
	private int lineSegment1Point2YCoor;
	private int lineSegment2Point1XCoor;
	private int lineSegment2Point1YCoor;
	private int lineSegment2Point2XCoor;
	private int lineSegment2Point2YCoor;
	private int shapeCenterPointXCoor;
	private int shapeCenterPointYCoor;
	private int convertedEstimateLoss;

	public GraphicMicroBustProductSubBlock() {

	}

	public GraphicMicroBustProductSubBlock(int x1, int y1, int x2, int y2, int radius, int loss, short solidShape) {
		this.centerPoint1XCoordinate = x1;
		this.centerPoint1YCoordinate = y1;
		this.centerPoint2XCoordinate = x2;
		this.centerPoint2YCoordinate = y2;
		this.microburstShapeRadius = radius;
		this.convertedEstimateLoss = loss;
		this.solidShape = solidShape;
	}

	public byte[] toByteArray() {
		ByteBuffer br = ByteBuffer.allocate(MSG_LEN);
		br.put(ByteUtil.to2Bytes(microburstShapeRadius / 15));
		br.put(ByteUtil.EMPTY_1B);
		br.put(ByteUtil.toByte(solidShape));
		br.put(ByteUtil.to2Bytes(shapeAngularOrientation));
		br.put(ByteUtil.to2Bytes(centerPoint1XCoordinate / 15));
		br.put(ByteUtil.to2Bytes(centerPoint1YCoordinate / 15));
		br.put(ByteUtil.to2Bytes(centerPoint2XCoordinate / 15));
		br.put(ByteUtil.to2Bytes(centerPoint2YCoordinate / 15));
		br.put(ByteUtil.to2Bytes(lineSegment1Point1XCoor / 15));
		br.put(ByteUtil.to2Bytes(lineSegment1Point1YCoor / 15));
		br.put(ByteUtil.to2Bytes(lineSegment1Point2XCoor / 15));
		br.put(ByteUtil.to2Bytes(lineSegment1Point2YCoor / 15));
		br.put(ByteUtil.to2Bytes(lineSegment2Point1XCoor / 15));
		br.put(ByteUtil.to2Bytes(lineSegment2Point1YCoor / 15));
		br.put(ByteUtil.to2Bytes(lineSegment2Point2XCoor / 15));
		br.put(ByteUtil.to2Bytes(lineSegment2Point2YCoor / 15));
		br.put(ByteUtil.to2Bytes(shapeCenterPointXCoor / 15));
		br.put(ByteUtil.to2Bytes(shapeCenterPointYCoor / 15));
		char tenth = (char) ((int) (convertedEstimateLoss % 100) / 10 + '0');
		char oneth = (char) (convertedEstimateLoss % 10 + '0');
		br.put(ByteUtil.toByte(tenth));
		br.put(ByteUtil.toByte(oneth));
		return br.array();
	}

	public String toString() {
		StringBuffer buf = new StringBuffer();
		buf.append(getMicroburstShapeRadius());
		buf.append(",");
		buf.append(getSolidShape());
		buf.append(",");
		buf.append(getCenterPoint1XCoordinate());
		buf.append(",");
		buf.append(getCenterPoint1YCoordinate());
		buf.append(",");
		buf.append(getCenterPoint2XCoordinate());
		buf.append(",");
		buf.append(getCenterPoint2YCoordinate());
		buf.append(",");
		buf.append(getConvertedEstimateLoss());
		return buf.toString();
	}

	public int getMicroburstShapeRadius() {
		return microburstShapeRadius;
	}

	public void setMicroburstShapeRadius(int microburstShapeRadius) {
		this.microburstShapeRadius = microburstShapeRadius;
	}

	public short getSolidShape() {
		return solidShape;
	}

	public void setSolidShape(short solidShape) {
		this.solidShape = solidShape;
	}

	public int getShapeAngularOrientation() {
		return shapeAngularOrientation;
	}

	public void setShapeAngularOrientation(int shapeAngularOrientation) {
		this.shapeAngularOrientation = shapeAngularOrientation;
	}

	public int getCenterPoint1XCoordinate() {
		return centerPoint1XCoordinate;
	}

	public void setCenterPoint1XCoordinate(int centerPoint1XCoordinate) {
		this.centerPoint1XCoordinate = centerPoint1XCoordinate;
	}

	public int getCenterPoint1YCoordinate() {
		return centerPoint1YCoordinate;
	}

	public void setCenterPoint1YCoordinate(int centerPoint1YCoordinate) {
		this.centerPoint1YCoordinate = centerPoint1YCoordinate;
	}

	public int getCenterPoint2XCoordinate() {
		return centerPoint2XCoordinate;
	}

	public void setCenterPoint2XCoordinate(int centerPoint2XCoordinate) {
		this.centerPoint2XCoordinate = centerPoint2XCoordinate;
	}

	public int getCenterPoint2YCoordinate() {
		return centerPoint2YCoordinate;
	}

	public void setCenterPoint2YCoordinate(int centerPoint2YCoordinate) {
		this.centerPoint2YCoordinate = centerPoint2YCoordinate;
	}

	public int getLineSegment1Point1XCoor() {
		return lineSegment1Point1XCoor;
	}

	public void setLineSegment1Point1XCoor(int lineSegment1Point1XCoor) {
		this.lineSegment1Point1XCoor = lineSegment1Point1XCoor;
	}

	public int getLineSegment1Point1YCoor() {
		return lineSegment1Point1YCoor;
	}

	public void setLineSegment1Point1YCoor(int lineSegment1Point1YCoor) {
		this.lineSegment1Point1YCoor = lineSegment1Point1YCoor;
	}

	public int getLineSegment1Point2XCoor() {
		return lineSegment1Point2XCoor;
	}

	public void setLineSegment1Point2XCoor(int lineSegment1Point2XCoor) {
		this.lineSegment1Point2XCoor = lineSegment1Point2XCoor;
	}

	public int getLineSegment1Point2YCoor() {
		return lineSegment1Point2YCoor;
	}

	public void setLineSegment1Point2YCoor(int lineSegment1Point2YCoor) {
		this.lineSegment1Point2YCoor = lineSegment1Point2YCoor;
	}

	public int getLineSegment2Point1XCoor() {
		return lineSegment2Point1XCoor;
	}

	public void setLineSegment2Point1XCoor(int lineSegment2Point1XCoor) {
		this.lineSegment2Point1XCoor = lineSegment2Point1XCoor;
	}

	public int getLineSegment2Point1YCoor() {
		return lineSegment2Point1YCoor;
	}

	public void setLineSegment2Point1YCoor(int lineSegment2Point1YCoor) {
		this.lineSegment2Point1YCoor = lineSegment2Point1YCoor;
	}

	public int getLineSegment2Point2XCoor() {
		return lineSegment2Point2XCoor;
	}

	public void setLineSegment2Point2XCoor(int lineSegment2Point2XCoor) {
		this.lineSegment2Point2XCoor = lineSegment2Point2XCoor;
	}

	public int getLineSegment2Point2YCoor() {
		return lineSegment2Point2YCoor;
	}

	public void setLineSegment2Point2YCoor(int lineSegment2Point2YCoor) {
		this.lineSegment2Point2YCoor = lineSegment2Point2YCoor;
	}

	public int getShapeCenterPointXCoor() {
		return shapeCenterPointXCoor;
	}

	public void setShapeCenterPointXCoor(int shapeCenterPointXCoor) {
		this.shapeCenterPointXCoor = shapeCenterPointXCoor;
	}

	public int getShapeCenterPointYCoor() {
		return shapeCenterPointYCoor;
	}

	public void setShapeCenterPointYCoor(int shapeCenterPointYCoor) {
		this.shapeCenterPointYCoor = shapeCenterPointYCoor;
	}

	public int getConvertedEstimateLoss() {
		return convertedEstimateLoss;
	}

	public void setConvertedEstimateLoss(int convertedEstimateLoss) {
		this.convertedEstimateLoss = convertedEstimateLoss;
	}
}
